<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="org.springframework.web.context.WebApplicationContext"%>
<%@page
	import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="db.SupplierDAO"%>
<%@ include file="/jsp/common/utility/volti.jsp" %>
<%@ include file="/jsp/common/utility/logined.jsp" %>
<%
	request.setCharacterEncoding("utf-8");

	WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
	SupplierDAO supplierDao = (SupplierDAO)ctx.getBean("SupplierDAO");
	
	Integer teamId = (Integer)session.getAttribute("tid");
	
	String pn_str = request.getParameter("pn");
	String keyword = request.getParameter("keyword");
	
	int pn = 0;
	int pageSize = 10;
	
	if(pn_str != null && !"".equals(pn_str)){
		try{
			pn = Integer.parseInt(pn_str);
		}catch(Exception e){
			pn = 0;
		}
	}
	
	if(keyword == null || "请输入关键字".equals(keyword)){
		keyword = "";
	}
	
	List list = new ArrayList();
	list.add(new Object[]{"like","name",keyword});
	list.add(new Object[]{"like","person",keyword});
	
	Map map = supplierDao.getSupplier(pn,pageSize,
	new String[][]{new String[]{"desc","date"}},
	new Object[][] {new Object[] { "or", "", list},
				new Object[] { "eq", "isDelete", new Integer(0) },
				new Object[] { "eq", "teamId", teamId }},
	new String[][]{new String[]{"","id"},new String[]{"","name"},new String[]{"","person"},new String[]{"","phone"}}
	,null);
	
	request.setAttribute("map",map);
	
	int pageTotal = ((Integer)map.get("pageTotal")).intValue();
	int pageNo = ((Integer)map.get("pageNo")).intValue();
	List pageList=getPage(pageTotal,pageNo);
	request.setAttribute("pages",pageList);
	
	request.setAttribute("keyword",keyword);
	
	pageContext.forward("/vm/supinfo/supinfo_list.vm");
%>